home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gdevdflt.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  8.4 KB  |  262 lines

  1. /* Copyright (C) 1995, 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gdevdflt.c,v 1.3 2000/09/19 19:00:12 lpd Exp $ */
  20. /* Default device implementation */
  21. #include "gx.h"
  22. #include "gserrors.h"
  23. #include "gsropt.h"
  24. #include "gxcomp.h"
  25. #include "gxdevice.h"
  26.  
  27. /* ---------------- Default device procedures ---------------- */
  28.  
  29. /* Fill in NULL procedures in a device procedure record. */
  30. void
  31. gx_device_fill_in_procs(register gx_device * dev)
  32. {
  33.     gx_device_set_procs(dev);
  34.     fill_dev_proc(dev, open_device, gx_default_open_device);
  35.     fill_dev_proc(dev, get_initial_matrix, gx_default_get_initial_matrix);
  36.     fill_dev_proc(dev, sync_output, gx_default_sync_output);
  37.     fill_dev_proc(dev, output_page, gx_default_output_page);
  38.     fill_dev_proc(dev, close_device, gx_default_close_device);
  39.     fill_dev_proc(dev, map_rgb_color, gx_default_map_rgb_color);
  40.     fill_dev_proc(dev, map_color_rgb, gx_default_map_color_rgb);
  41.     /* NOT fill_rectangle */
  42.     fill_dev_proc(dev, tile_rectangle, gx_default_tile_rectangle);
  43.     fill_dev_proc(dev, copy_mono, gx_default_copy_mono);
  44.     fill_dev_proc(dev, copy_color, gx_default_copy_color);
  45.     fill_dev_proc(dev, obsolete_draw_line, gx_default_draw_line);
  46.     fill_dev_proc(dev, get_bits, gx_default_get_bits);
  47.     fill_dev_proc(dev, get_params, gx_default_get_params);
  48.     fill_dev_proc(dev, put_params, gx_default_put_params);
  49.     fill_dev_proc(dev, map_cmyk_color, gx_default_map_cmyk_color);
  50.     fill_dev_proc(dev, get_xfont_procs, gx_default_get_xfont_procs);
  51.     fill_dev_proc(dev, get_xfont_device, gx_default_get_xfont_device);
  52.     fill_dev_proc(dev, map_rgb_alpha_color, gx_default_map_rgb_alpha_color);
  53.     fill_dev_proc(dev, get_page_device, gx_default_get_page_device);
  54.     fill_dev_proc(dev, get_alpha_bits, gx_default_get_alpha_bits);
  55.     fill_dev_proc(dev, copy_alpha, gx_default_copy_alpha);
  56.     fill_dev_proc(dev, get_band, gx_default_get_band);
  57.     fill_dev_proc(dev, copy_rop, gx_default_copy_rop);
  58.     fill_dev_proc(dev, fill_path, gx_default_fill_path);
  59.     fill_dev_proc(dev, stroke_path, gx_default_stroke_path);
  60.     fill_dev_proc(dev, fill_mask, gx_default_fill_mask);
  61.     fill_dev_proc(dev, fill_trapezoid, gx_default_fill_trapezoid);
  62.     fill_dev_proc(dev, fill_parallelogram, gx_default_fill_parallelogram);
  63.     fill_dev_proc(dev, fill_triangle, gx_default_fill_triangle);
  64.     fill_dev_proc(dev, draw_thin_line, gx_default_draw_thin_line);
  65.     fill_dev_proc(dev, begin_image, gx_default_begin_image);
  66.     /*
  67.      * We always replace get_alpha_bits, image_data, and end_image with the
  68.      * new procedures, and, if in a DEBUG configuration, print a warning if
  69.      * the definitions aren't the default ones.
  70.      */
  71. #ifdef DEBUG
  72. #  define CHECK_NON_DEFAULT(proc, default, procname)\
  73.     BEGIN\
  74.     if ( dev_proc(dev, proc) != NULL && dev_proc(dev, proc) != default )\
  75.         dprintf2("**** Warning: device %s implements obsolete procedure %s\n",\
  76.              dev->dname, procname);\
  77.     END
  78. #else
  79. #  define CHECK_NON_DEFAULT(proc, default, procname)\
  80.     DO_NOTHING
  81. #endif
  82.     CHECK_NON_DEFAULT(get_alpha_bits, gx_default_get_alpha_bits,
  83.               "get_alpha_bits");
  84.     set_dev_proc(dev, get_alpha_bits, gx_default_get_alpha_bits);
  85.     CHECK_NON_DEFAULT(image_data, gx_default_image_data, "image_data");
  86.     set_dev_proc(dev, image_data, gx_default_image_data);
  87.     CHECK_NON_DEFAULT(end_image, gx_default_end_image, "end_image");
  88.     set_dev_proc(dev, end_image, gx_default_end_image);
  89. #undef CHECK_NON_DEFAULT
  90.     fill_dev_proc(dev, strip_tile_rectangle, gx_default_strip_tile_rectangle);
  91.     fill_dev_proc(dev, strip_copy_rop, gx_default_strip_copy_rop);
  92.     fill_dev_proc(dev, get_clipping_box, gx_default_get_clipping_box);
  93.     fill_dev_proc(dev, begin_typed_image, gx_default_begin_typed_image);
  94.     fill_dev_proc(dev, get_bits_rectangle, gx_default_get_bits_rectangle);
  95.     fill_dev_proc(dev, map_color_rgb_alpha, gx_default_map_color_rgb_alpha);
  96.     fill_dev_proc(dev, create_compositor, gx_default_create_compositor);
  97.     fill_dev_proc(dev, get_hardware_params, gx_default_get_hardware_params);
  98.     fill_dev_proc(dev, text_begin, gx_default_text_begin);
  99.     fill_dev_proc(dev, finish_copydevice, gx_default_finish_copydevice);
  100. }
  101.  
  102. int
  103. gx_default_open_device(gx_device * dev)
  104. {
  105.     return 0;
  106. }
  107.  
  108. /* Get the initial matrix for a device with inverted Y. */
  109. /* This includes essentially all printers and displays. */
  110. void
  111. gx_default_get_initial_matrix(gx_device * dev, register gs_matrix * pmat)
  112. {
  113.     pmat->xx = dev->HWResolution[0] / 72.0;    /* x_pixels_per_inch */
  114.     pmat->xy = 0;
  115.     pmat->yx = 0;
  116.     pmat->yy = dev->HWResolution[1] / -72.0;    /* y_pixels_per_inch */
  117.     /****** tx/y is WRONG for devices with ******/
  118.     /****** arbitrary initial matrix ******/
  119.     pmat->tx = 0;
  120.     pmat->ty = dev->height;
  121. }
  122. /* Get the initial matrix for a device with upright Y. */
  123. /* This includes just a few printers and window systems. */
  124. void
  125. gx_upright_get_initial_matrix(gx_device * dev, register gs_matrix * pmat)
  126. {
  127.     pmat->xx = dev->HWResolution[0] / 72.0;    /* x_pixels_per_inch */
  128.     pmat->xy = 0;
  129.     pmat->yx = 0;
  130.     pmat->yy = dev->HWResolution[1] / 72.0;    /* y_pixels_per_inch */
  131.     /****** tx/y is WRONG for devices with ******/
  132.     /****** arbitrary initial matrix ******/
  133.     pmat->tx = 0;
  134.     pmat->ty = 0;
  135. }
  136.  
  137. int
  138. gx_default_sync_output(gx_device * dev)
  139. {
  140.     return 0;
  141. }
  142.  
  143. int
  144. gx_default_output_page(gx_device * dev, int num_copies, int flush)
  145. {
  146.     int code = dev_proc(dev, sync_output)(dev);
  147.  
  148.     if (code >= 0)
  149.     code = gx_finish_output_page(dev, num_copies, flush);
  150.     return code;
  151. }
  152.  
  153. int
  154. gx_default_close_device(gx_device * dev)
  155. {
  156.     return 0;
  157. }
  158.  
  159. const gx_xfont_procs *
  160. gx_default_get_xfont_procs(gx_device * dev)
  161. {
  162.     return NULL;
  163. }
  164.  
  165. gx_device *
  166. gx_default_get_xfont_device(gx_device * dev)
  167. {
  168.     return dev;
  169. }
  170.  
  171. gx_device *
  172. gx_default_get_page_device(gx_device * dev)
  173. {
  174.     return NULL;
  175. }
  176. gx_device *
  177. gx_page_device_get_page_device(gx_device * dev)
  178. {
  179.     return dev;
  180. }
  181.  
  182. int
  183. gx_default_get_alpha_bits(gx_device * dev, graphics_object_type type)
  184. {
  185.     return (type == go_text ? dev->color_info.anti_alias.text_bits :
  186.         dev->color_info.anti_alias.graphics_bits);
  187. }
  188.  
  189. int
  190. gx_default_get_band(gx_device * dev, int y, int *band_start)
  191. {
  192.     return 0;
  193. }
  194.  
  195. void
  196. gx_default_get_clipping_box(gx_device * dev, gs_fixed_rect * pbox)
  197. {
  198.     pbox->p.x = 0;
  199.     pbox->p.y = 0;
  200.     pbox->q.x = int2fixed(dev->width);
  201.     pbox->q.y = int2fixed(dev->height);
  202. }
  203. void
  204. gx_get_largest_clipping_box(gx_device * dev, gs_fixed_rect * pbox)
  205. {
  206.     pbox->p.x = min_fixed;
  207.     pbox->p.y = min_fixed;
  208.     pbox->q.x = max_fixed;
  209.     pbox->q.y = max_fixed;
  210. }
  211.  
  212. int
  213. gx_no_create_compositor(gx_device * dev, gx_device ** pcdev,
  214.             const gs_composite_t * pcte,
  215.             const gs_imager_state * pis, gs_memory_t * memory)
  216. {
  217.     return_error(gs_error_unknownerror);    /* not implemented */
  218. }
  219. int
  220. gx_default_create_compositor(gx_device * dev, gx_device ** pcdev,
  221.                  const gs_composite_t * pcte,
  222.                  const gs_imager_state * pis, gs_memory_t * memory)
  223. {
  224.     return pcte->type->procs.create_default_compositor
  225.     (pcte, pcdev, dev, pis, memory);
  226. }
  227. int
  228. gx_null_create_compositor(gx_device * dev, gx_device ** pcdev,
  229.               const gs_composite_t * pcte,
  230.               const gs_imager_state * pis, gs_memory_t * memory)
  231. {
  232.     *pcdev = dev;
  233.     return 0;
  234. }
  235.  
  236. int
  237. gx_default_finish_copydevice(gx_device *dev, const gx_device *from_dev)
  238. {
  239.     /* Only allow copying the prototype. */
  240.     return (from_dev->memory ? gs_note_error(gs_error_rangecheck) : 0);
  241. }
  242.  
  243. /* ---------------- Default per-instance procedures ---------------- */
  244.  
  245. int
  246. gx_default_install(gx_device * dev, gs_state * pgs)
  247. {
  248.     return 0;
  249. }
  250.  
  251. int
  252. gx_default_begin_page(gx_device * dev, gs_state * pgs)
  253. {
  254.     return 0;
  255. }
  256.  
  257. int
  258. gx_default_end_page(gx_device * dev, int reason, gs_state * pgs)
  259. {
  260.     return (reason != 2 ? 1 : 0);
  261. }
  262.